package com.sample.prdownloader.slics;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import ohos.app.Environment;

import com.prdownloader.PRDownloader;
import com.prdownloader.PRDownloaderConfig;
import com.prdownloader.request.DownloadRequestBuilder;
import com.sample.prdownloader.ResourceTable;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class MainAbilitySliceOhosTest {
    Context context;
    private String url;
    private String dirPath;
    @Before
    public void setUp() throws Exception {
        context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        url = context.getString(ResourceTable.String_mUrl1);
        dirPath = context.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath();
        PRDownloaderConfig config = PRDownloaderConfig.newBuilder()
            .setDatabaseEnabled(true)
            .build();
        PRDownloader.initialize(context, config);
    }
    @After
    public void testClose() throws Exception {
        PRDownloader.shutDown();
    }

    @Test
    public void onStart() {
        new DownloadRequestBuilder(url, dirPath, "10mb.mp4");
    }
}
